<!DOCTYPE html>
<!-- 请使用 serve 打开此demo页 -->
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
    <h1>Hello App!</h1>
        <p>
            <router-link to="/foo">Go to Foo</router-link>
            <router-link to="/bar">Go to Bar</router-link>
        </p>
        <router-view></router-view>
    </div>
    <script src="./vue.js"></script>
    <script type="module">
        import VueRouter from './vuerouter/index.js'
        Vue.use(VueRouter)
        const Foo = { template: '<div>foo</div>' }
        const Bar = { template: '<div>bar</div>' }
        const Home = {template:'<div>home</div>'}
        // 2. 定义路由
        
        const routes = [
        { path: '/', component:Home},
        { path: '/foo', component: Foo },
        { path: '/bar', component: Bar }
        ]

        // 3. 创建 router 实例，然后传 `routes` 配置

        const router = new VueRouter({
            routes 
        })

        // 4. 创建和挂载根实例。
        const app = new Vue({
            router
        }).$mount('#app')

    </script>
</body>
</html>